#!/bin/bash
#############################################################
# Name:        Supportconfig Plugin for NOWS SBE HylaFAX
# Description: Gathers HylaFAX troubleshooting information
# License:     GPLv2
# Author:      Randy Goddard (randage@gmail.com)
#              Jason Record (jrecord@novell.com)
# Modified:    2010 Oct 21
#############################################################

SVER=2.02
RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"
LOG_LINES=500	#0 means include the entire file
LOG_DIR="/var/spool/hylafax/log"
CONF_DIR="/etc/hylafax"

[ -s $RCFILE ] && . $RCFILE || { echo "ERROR: Initializing resource file: $RCFILE"; exit 1; }

section_header "Supportconfig Plugin for NOWS SBE HylaFAX, v${SVER}"

plugin_command "rpm -qa | egrep -i 'hylafax' | sort"
RPMLIST=$(rpm -qa | egrep -i 'hylafax' | sort)
if [ -z "$RPMLIST" ]; then
  echo "ERROR: HylaFAX package(s) not installed"
  echo
  exit 111
fi

for THISRPM in $RPMLIST
do
   validate_rpm $THISRPM
done

for i in hylafax
do
	if [ -s /etc/init.d/$i ]; then
		plugin_command "chkconfig -l $i"
		plugin_command "/etc/init.d/$i status"
	fi
done

plugin_command "ps axwwo user,pid,ppid,%cpu,%mem,vsz,rss,stat,time,cmd | egrep 'hylafax' | egrep -v 'nowsbe_|grep'"

FILES=$(find $CONF_DIR -maxdepth 1 -type f)
pconf_files $FILES
FILES=$(find $LOG_DIR -maxdepth 1 -type f)
[ -n "$FILES" ] && plog_files $LOG_LINES $FILES || section_header "No log files found in $LOG_DIR"


